﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Routing;
using System.Web.Mvc;
using TidyBlog.Entity;
using TidyBlog.BLL;

namespace TidyBlog.MVC
{
    public class ManageActionFilter : BaseActionFilter
    {
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);

            dynamic viewBag = filterContext.Controller.ViewBag;
            viewBag.Title += " 后台管理";

            // 基本权限检查
            if (CurrentUser == null)
            {
                RespondentInfo.Error(filterContext, new OperInfo()
                {
                    Message = "权限不足",
                    Link = new UrlHelper(filterContext.RequestContext).Action("Login", "User") +
                        "?redirect=" + filterContext.HttpContext.Request.Url,
                    LinkText = "登录"
                });
            }
        }
    }
}
